package DataStorageAccess;
import java.beans.XMLDecoder;
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import ProgramLogic.MediaManager;

public class XMLtoData {

    public static MediaManager load() {
	XMLDecoder decoder = null;
	try {
	    decoder = new XMLDecoder(new BufferedInputStream(
		    new FileInputStream("./mediamanager.xml")));
	} catch (FileNotFoundException e) {
	    try {
		DataToXML.save(MediaManager.getInstance());
	    } catch (IOException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	    }
	    load();
	}
	Object result = decoder.readObject();
	decoder.close();
	return (MediaManager) result;
    }
}
